package com.shop.shop.service.impl;

import java.util.List;

import com.shop.shop.dao.ShopCarMapper;
import com.shop.shop.domain.ShopCar;
import com.shop.shop.service.IShopCarService;
import com.vip.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 购物车Service业务层处理
 * 
 * @author
 */
@Service
public class ShopCarServiceImpl implements IShopCarService
{
    @Autowired
    private ShopCarMapper shopCarMapper;

    /**
     * 查询购物车
     * 
     * @param carId 购物车主键
     * @return 购物车
     */
    @Override
    public ShopCar selectShopCarByCarId(Long carId)
    {
        return shopCarMapper.selectShopCarByCarId(carId);
    }

    /**
     * 查询购物车列表
     * 
     * @param shopCar 购物车
     * @return 购物车
     */
    @Override
    public List<ShopCar> selectShopCarList(ShopCar shopCar)
    {
        return shopCarMapper.selectShopCarList(shopCar);
    }

    /**
     * 新增购物车
     * 
     * @param shopCar 购物车
     * @return 结果
     */
    @Override
    public int insertShopCar(ShopCar shopCar)
    {
        shopCar.setCreateTime(DateUtils.getNowDate());
        return shopCarMapper.insertShopCar(shopCar);
    }

    /**
     * 修改购物车
     * 
     * @param shopCar 购物车
     * @return 结果
     */
    @Override
    public int updateShopCar(ShopCar shopCar)
    {
        shopCar.setUpdateTime(DateUtils.getNowDate());
        return shopCarMapper.updateShopCar(shopCar);
    }

    /**
     * 批量删除购物车
     * 
     * @param carIds 需要删除的购物车主键
     * @return 结果
     */
    @Override
    public int deleteShopCarByCarIds(Long[] carIds)
    {
        return shopCarMapper.deleteShopCarByCarIds(carIds);
    }

    /**
     * 删除购物车信息
     * 
     * @param carId 购物车主键
     * @return 结果
     */
    @Override
    public int deleteShopCarByCarId(Long carId)
    {
        return shopCarMapper.deleteShopCarByCarId(carId);
    }
}
